﻿Imports System.IO
Public Class frmScreenSHot

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Function TakeShotOfScreens() As Bitmap
        Dim maxHeight As Integer = 0
        Dim maxWidth As Integer = 0
        For Each scr As Screen In Screen.AllScreens
            maxWidth += scr.Bounds.Width
            If scr.Bounds.Height > maxHeight Then maxHeight = scr.Bounds.Height
        Next
        Dim allScreensCapture As New Bitmap(maxWidth, maxHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
        Dim screenGrab As Bitmap
        Dim screenSize As Size
        Dim g As Graphics
        Dim g2 As Graphics = Graphics.FromImage(allScreensCapture)
        Dim a As New Point(0, 0)
        For Each scr As Screen In Screen.AllScreens
            screenSize = New Size(scr.Bounds.Width, scr.Bounds.Height)
            screenGrab = New Bitmap(scr.Bounds.Width, scr.Bounds.Height)
            g = Graphics.FromImage(screenGrab)
            g.CopyFromScreen(a, New Point(0, 0), screenSize)
            g2.DrawImage(screenGrab, a)
            a.X += scr.Bounds.Width
        Next
        Return allScreensCapture
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Opacity = 0
        PictureBox1.Image = TakeShotOfScreens()
        Me.Opacity = 100
        Dim bmp As Bitmap = PictureBox1.Image
        Select Case (ComboBox1.Text)
            Case "jpg"
                bmp.Save("1.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
            Case "bmp"
                bmp.Save("1.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
            Case "png"
                bmp.Save("1.png", System.Drawing.Imaging.ImageFormat.Png)
            Case ""

        End Select
    End Sub
End Class
